var e = require("../../../utils/function.js"), a = require("../../../api.js"), n = getApp(), t = e.driverImg;

Page({
    data: {
        img: e.driverImg,
        avatar: t + "icon-12.png",
        name: "",
        orderCount: 0,
        income: 0,
        evaluate: [],
        myTask: [],
        handler: [],
        serverPhone: "",
        is_complete: 0
    },
    onLoad: function(e) {
        e.uid && n.shareCouponsMessage(e.uid);
    },
    onReady: function() {},
    intoPageHandler: function(a) {
        n.request({
            url: "https://dishichuxing.cn/api.php/?s=promise_money/index",
            method: "post",
            data: {},
            success: (res)=> {
                if(res.data.status==1){
                    e.intoPageHandler(a.currentTarget.dataset.skip);
                }else{
                    wx.showToast({
                        title: "暂未开放",
                        icon: "none"
                    })
                }
            }
        });
        
    },
    callPhoneHandler: function(a) {
        var n = a.currentTarget.dataset.phone;
        e.callPhoneHandler(n || wx.getStorageSync("customer"));
    },
    onShow: function() {
        var e = this;
        n.request({
            url: a.driver.personal,
            method: "post",
            data: {},
            success: function(a) {
                console.log(a)
                e.setData({
                    avatar: a.data.avatar_url,
                    name: a.data.nickname,
                    orderCount: a.data.ordernum,
                    evaluate: a.data.commentnum,
                    income: a.data.income,
                    is_complete: a.data.is_complete
                });
            }
        });
    },
    loginoutHandler: function() {
        wx.showModal({
            title: "代驾人员",
            content: "确定退出?",
            success: function(e) {
                e.confirm && n.request({
                    url: a.user.loginout,
                    method: "post",
                    data: {},
                    success: function(e) {
                        1 == e.code && (wx.removeStorage({
                            key: "userMessage"
                        }), wx.removeStorage({
                            key: "phonep"
                        }), wx.removeStorage({
                            key: "access_token"
                        }), wx.reLaunch({
                            url: "../../map/driverServer/driverServer"
                        }));
                    }
                });
            },
            fail: function() {
                wx, wx.showToast({
                    title: "退出失败",
                    icon: "none"
                });
            }
        });
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {
        return {
            title: n.shareAppMessage().title,
            imageUrl: n.shareAppMessage().imageUrl,
            desc: n.shareAppMessage().desc,
            path: n.shareAppMessage().path
        };
    }
});